/**
 * Created on 10 avr. 08 by Sebastian Audet
 */
package grid;

import java.util.ArrayList;
import java.util.Collection;


/**
 * @author Sebastian Audet
 *
 */
public class HexGrid extends AbstractGrid {
    
    public HexGrid(int i, int j) {
	super(i,j);
    }
    
    @Override
    public Collection<Node> getNeighborNodesCollection(Node node) {
	Collection<Node> nodes = new ArrayList<Node>();
	Location loc = node.getLocation();
	ArrayList<Location> locs = new ArrayList<Location>();
	
	//LocationMap
	locs.add(new Location(loc.x-1,loc.y-1));
	locs.add(new Location(loc.x,loc.y-2));
	locs.add(new Location(loc.x+1,loc.y-1));
	locs.add(new Location(loc.x-1,loc.y+1));
	locs.add(new Location(loc.x,loc.y+2));
	locs.add(new Location(loc.x+1,loc.y+1));
	
	for(Location l:locs)
	{
	    try
	    {
		nodes.add(getNode(l));
	    }
	    catch (GridOutOfBounds e)
	    {
		//Simply means it can't be added, move on
	    }
	}
	return nodes;
    }

    @Override
    public int returnGridType() {
	return Grid.HEXAGON;
    }
}
